angular.module('product',[])
//数据用factory或service解决，尽量不要写在controller里面
//数据基本上都是通过后端去取得的，通过http、ajax去取得
.service('productData',function () {
    return[
        {
            id:3333,
            name:'iphone',
            price:5400
        },
        {
            id:3336,
            name:'ipad',
            price:3400
        },
        {
            id:3339,
            name:'imac',
            price:15400
        },
        {
            id:3342,
            name:'ipad air',
            price:2340
        },
        {
            id:3345,
            name:'ipad mini',
            price:2200
        }
    ]
})

.controller('productController',['$scope','productData',function ($scope,productData) {

    $scope.productData = productData;

    $scope.order = '';

    $scope.orderType = 'id';
    
    $scope.changeOrder = function (type) {
        $scope.orderType = type;
        if($scope.order === ''){
            $scope.order = '-'
        }else if($scope.order === '-'){
            $scope.order =''
        }
    }

}])